package cn.mulanbay.api.system.factory;

import cn.mulanbay.api.system.bean.RemoteRoleUrlAuthRequest;
import cn.mulanbay.api.system.service.RemoteRoleService;
import cn.mulanbay.common.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * 角色服务降级处理
 *
 * @author fenghong
 */
public class RemoteRoleFallbackFactory implements FallbackFactory<RemoteRoleService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteRoleFallbackFactory.class);

    @Override
    public RemoteRoleService create(Throwable throwable) {

        log.error("用户服务调用失败:{}", throwable.getMessage());

        return new RemoteRoleService() {
            @Override
            public R<Integer> isUrlAuth(RemoteRoleUrlAuthRequest uar) {
                return R.fail("url授权认证失败:" + throwable.getMessage());
            }
        };
    }
}
